package Demo;

public class Test {
    public static void main(String[] args) {
        String str = "hello world hello bit" ;
        String[] result = str.split(" ",3) ; // 按照空格拆分
        for(String s: result) {
            System.out.println(s);
        }
    }
    public static void main4(String[] args) {
        String str = "helloworld" ;
        System.out.println(str.replaceAll("l", "_"));
        System.out.println(str.replaceFirst("l", "_"));
    }
    public static void main3(String[] args) {
        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);
    }
    public static void main2(String[] args) {
        String s = "hello";
        // 字符串转数组
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.print(ch[i]);
        }
        System.out.println();
        // 数组转字符串
        String s2 = new String(ch);
        System.out.println(s2);
    }
    public static void main1(String[] args) {
        String str="manlebron";
        System.out.println(str.indexOf("le"));
    }
}
